import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// webpackChunkName 这条注释还是很有必要加的，至少你打包后知道又是哪个页面变得又臭又大。
const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: () => import(/* webpackChunkName: "HomeView" */ '@/views/home/HomeView.vue')
  },
]

const router = new VueRouter({
  base: process.env.BASE_URL,
  mode: 'hash',
  routes,
  // 滚动行为，切换路由滚动到什么位置
  scrollBehavior (to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    return { y: 0 }
  }
})


router.beforeEach((to, from, next) => {
  next()
})
export default router
